// pages/logs/order/details/details.js by_class 
const app = getApp()
const connector = require('../../../../utils/connector.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bar_Height: wx.getSystemInfoSync().statusBarHeight + 45,
    orderOnes:{},
    types:'',//1=>从商品下单进入（取消付款）2=>从订单列表进入

  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this

    sundryOrderDetail(that, JSON.parse(options.queryBean))

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this
    wx.hideShareMenu()
   
  },
  /**
    * 页面相关事件处理函数--监听用户下拉动作
    */
   onPullDownRefresh: function () {
    var that = this
    wx.hideNavigationBarLoading() //完成停止加载
    wx.stopPullDownRefresh() //停止下拉刷新

  },
  orderAnew(e){
    
  },
  // /**支付 */
  // orderPay(e){
  //   var that = this;
  //   var cartNew = [];
  //   console.log(that.data.orderOnes)
  //   preOrder(that, that.data.orderOnes.order_id)
  // },
  /**取消订单 */
  orderCancel(e){
    var that = this;
    // let detailsid = that.data.orderOnes.data.id;
    
    wx.showModal({
      title: "取消订单",
      content: "您确定取消订单吗？",
      confirmText: "确定",
      cancelText: "取消",
      success: function (res) {
        if (res.confirm) {
          orderCancel(that)
        }
      }
    })
  },


  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },


  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  }
})
//获取订单详情
function sundryOrderDetail(that, orderSn) {
  // console.log(orderSn)
  connector.getFunc(connector.connector().sundryOrderDetail + orderSn, "", "get", app.tokens, function (res) {
    if (res.statusCode == 200) {
      // console.log(res.data)
      that.setData({
        orderOnes: res.data
      })
    }
  }, function (res) {
    wx.showToast({
      title: "内部错误",
      icon: 'none',
      duration: 1000
    })
  })
}

